<?php

namespace app\controller;

use app\BaseController;

use app\model\CertificateModel;
use app\services\JsonService;

class Index extends BaseController
{

    public function index()
    {
        return 'hello student';
    }


    // 获取证书列表
    public function get_certificate_list()
    {
        try {
            $param= $this->request->post();
            $this->handleParams($param, 'Certificate.certificate');
            $model = new CertificateModel();
            $data = $model->getCertificateListByNumber($param['id_number'],$param['cert_number']);
            JsonService::success('success', $data);
        } catch (\Exception $e) {
            JsonService::fail($e->getMessage());
        }
    }

    // 获取证书列表机构
    public function get_certificate_list_institution()
    {
        try {
            $param= $this->request->post();
            $this->handleParams($param, 'Certificate.certificate');
            $model = new CertificateModel();
            $data = $model->getCertificateListByInstitution($param['cert_number'],$param['institution']);
            JsonService::success('success', $data);
        } catch (\Exception $e){
            JsonService::fail($e->getMessage());
        }
    }
}